package util;

public class RateUtil {
	
	public static int getRate(double rating){
		rating = get2DigitPrec(rating);
		int last = (int) (Math.ceil((rating*10))%10);
		if(last < 2.5){
			last = 0;
		}else if(last < 7.5){
			last = 5;
		}else if(last < 10){
			last = 10;
		}
		int result = (int) (rating*10 - (rating*10)%10 + last);
		if(result%10 == 0){
			result = result / 10;
		}
		return result;
	}
	
	public static double get2DigitPrec(double a){
		return (double)Math.round(a * 10) / 10;
	}

}
